<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office" ddwrt:ghost="show_all">
	<xsl:include href="/_layouts/xsl/main.xsl"/>
	<xsl:include href="/_layouts/xsl/internal.xsl"/>
	<xsl:include href="/_layouts/xsl/BoldBrick.SharePoint.CommonControls/CommonTemplates.xsl"/>

	<xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]"/>

	<xsl:param name="InterviewWorkflowStepContentTypeID">0x0100FAF3E03D4A0E42FC93F208DFEDA7E407009B122952AD0B4B4BA624140987AA352F</xsl:param>
	<xsl:param name="ReferenceCallWorkflowStepContentTypeID">0x0100FAF3E03D4A0E42FC93F208DFEDA7E40700E43F30DCAD5940758FAABAEAA0AD980C</xsl:param>
	<xsl:param name="TestWorkflowStepContentTypeID">0x0100FAF3E03D4A0E42FC93F208DFEDA7E40700435DB74E1A5B4FDCB77CE1626212E928</xsl:param>

	<xsl:template match="View[(@BaseViewID='1')]" mode="full">
		<script type="text/javascript" src="/_layouts/BoldBrick.SharePoint.CommonControls/JS/SPHelper.js">
		</script>
		<script type="text/javascript" src="/_layouts/BoldBrick.OneIntranet.HR/JS/Workflows.js">
		</script>
		<link rel="stylesheet" type="text/css" href="/_layouts/BoldBrick.OneIntranet.HR/Style/WorkflowSteps.css"/>

		<!-- render IDs of all controls to disable during action -->
		<script type="text/javascript">

			var itemIds = new Array(
			<xsl:for-each select="$AllRows">
				<xsl:variable name="position" select="position()" />
				<xsl:if test="$position > 1">
					<xsl:text>,</xsl:text>
				</xsl:if>
				<xsl:value-of select="./@ID"/>
			</xsl:for-each>
			);
			var elementsToDisable = new Array(
			<xsl:for-each select="$AllRows">
				<xsl:variable name="item" select="." />
				<xsl:variable name="itemID" select="$item/@ID" />
				<xsl:variable name="position" select="position()" />
				<xsl:if test="$position > 1">
					<xsl:text>,</xsl:text>
				</xsl:if>

				<!-- buttonDelete -->
				<xsl:text>"buttonDelete_</xsl:text>
				<xsl:value-of select="$itemID"/>
				<xsl:text>"</xsl:text>

				<!-- buttonUp -->
				<xsl:text>,"buttonUp_</xsl:text>
				<xsl:value-of select="$itemID"/>
				<xsl:text>"</xsl:text>

				<!-- buttonDown -->
				<xsl:text>,"buttonDown_</xsl:text>
				<xsl:value-of select="$itemID"/>
				<xsl:text>"</xsl:text>
			</xsl:for-each>
			);
		</script>
		<div />
		<!-- Set fields -->
		<xsl:variable name="fields" select="ViewFields/FieldRef[not(@Explicit='TRUE')]"></xsl:variable>
		<xsl:variable name="view" select="."></xsl:variable>

		<div class="workflowStepMainDiv">
			
					<!--<textarea name="promenna" cols="150" rows="30">
						<xsl:copy-of select="count($AllRows)"/>
						<xsl:value-of select="count($AllRows)"/>
			</textarea>-->
					<xsl:variable name="rowCount" select="count($AllRows)" />
					<!-- Go through all rows -->
					<xsl:for-each select="$AllRows">
						<xsl:variable name="position" select="position()" />
						<xsl:variable name="item" select="." />
						<xsl:variable name="contentTypeID" select="$item/@ContentTypeId" />
						<xsl:variable name="itemID" select="$item/@ID" />

						<xsl:if test="$position > 1">
							<div class="workflowStepArrow">
								<img alt="" src="/_layouts/images/TPMAX1.GIF"/>
							</div>
						</xsl:if>
						<div class="workflowStepOneStep">
							<div class="workflowStepHeaderDiv">

								<span class="workflowStepNumber">
									<xsl:value-of select="$position"/>
									<xsl:text>.</xsl:text>
								</span>
								<span class="workflowStepHeaderLink">
									<b>
										<a onfocus="OnLink(this)" href="{$FORM_DISPLAY}&amp;ID={$itemID}&amp;ContentTypeID={$contentTypeID}"
											onclick="EditLink2(this,{$ViewCounter});return false;" target="_self">
											<xsl:value-of select="$item/@ContentType"/>
										</a>
									</b>
								</span>
								<span class="workflowStepButtons">
									<span class="workflowStepButtonUp">
										<xsl:if test="$position != 1">
											<a id="buttonUp_{$itemID}" onclick="moveStep('{$ServerRelativeUrl}', '{$ListTitle}', {$position}, elementsToDisable, true);" style="cursor: hand;">
												<img alt="" src="/_layouts/images/ARRUPA.GIF"/>
											</a>
										</xsl:if>
										<xsl:if test="$position = 1">
											<img alt="" src="/_layouts/images/ARRUPI.GIF"/>
										</xsl:if>
									</span>
									<span class="workflowStepButtonDown">
										<xsl:if test="$rowCount = $position">
											<img alt="" src="/_layouts/images/ARRDOWNI.GIF"/>
										</xsl:if>
										<xsl:if test="$rowCount != $position">
											<a id="buttonDown_{$itemID}" onclick="moveStep('{$ServerRelativeUrl}', '{$ListTitle}', {$position}, elementsToDisable, false);" style="cursor: hand;">
												<img alt="" src="/_layouts/images/ARRDOWNA.GIF"/>
											</a>
										</xsl:if>
									</span>
									<span class="workflowStepButtonDelete">
										<a id="buttonDelete_{$itemID}" onclick="confirmDeleteListItem('{$ServerRelativeUrl}', '{$ListTitle}', {$itemID}, elementsToDisable);" style="cursor: hand;">
											<img alt="" src="/_layouts/images/DELITEM.GIF"/>
										</a>
									</span>
								</span>

							</div>
							<div class="workflowStepItem">
								<span class="workflowStepName">
									<xsl:value-of select="$fields[@Name='TaskOwner']/@DisplayName"></xsl:value-of>
									<xsl:text>:</xsl:text>
								</span>
								<span class="workflowStepValue">
									<xsl:call-template name="userAnchorOnly">
										<xsl:with-param name="userElement" select="$item/@TaskOwner" />
									</xsl:call-template>
								</span>
							</div>
							<xsl:choose>
								<xsl:when test="starts-with($contentTypeID, $InterviewWorkflowStepContentTypeID)">
									<xsl:call-template name="InterviewWorkflowStepView">
										<xsl:with-param name="fields" select="$fields"></xsl:with-param>
									</xsl:call-template>
								</xsl:when>
								<xsl:when test="starts-with($contentTypeID, $ReferenceCallWorkflowStepContentTypeID)">
									<xsl:call-template name="ReferenceCallWorkflowStepView">
										<xsl:with-param name="fields" select="$fields"></xsl:with-param>
									</xsl:call-template>
								</xsl:when>
								<xsl:when test="starts-with($contentTypeID, $TestWorkflowStepContentTypeID)">
									<xsl:call-template name="TestWorkflowStepView">
										<xsl:with-param name="fields" select="$fields"></xsl:with-param>
									</xsl:call-template>
								</xsl:when>
							</xsl:choose>
						</div>

						<!--<div>
				<table>
					<tr>
						<td><b>Attribute Name</b></td>
						<td><b>Attribute value</b></td>
					</tr>
				<xsl:for-each select="@*">
					<tr>
					<td>
						<xsl:value-of select="name()"/>
					</td>
					<td>
						<xsl:value-of select="."/>
					</td>
					</tr>
				</xsl:for-each>
				</table>
			</div>-->
						<!--<textarea name="promenna" cols="150" rows="30">
				<xsl:copy-of select="$FORM_DISPLAY"/>
				<xsl:value-of select="$FORM_DISPLAY"/>
			</textarea>-->

						<!--
			<xsl:value-of select="$Fields[@Name='DocumentTypeLookup']/@DisplayName"></xsl:value-of>
			-->

					</xsl:for-each>


				</div>
	</xsl:template>
	<xsl:template name="InterviewWorkflowStepView" >
		<xsl:param name="fields"/>
		<xsl:variable name="item" select="." />
		<div class="workflowStepItem">
			<span class="workflowStepName">
				<xsl:value-of select="$fields[@Name='Interviewer']/@DisplayName"></xsl:value-of>
				<xsl:text>:</xsl:text>
			</span>
			<span class="workflowStepValue">
				<xsl:call-template name="userAnchorOnly">
					<xsl:with-param name="userElement" select="$item/@Interviewer" />
				</xsl:call-template>
			</span>
		</div>
	</xsl:template>
	<xsl:template name="ReferenceCallWorkflowStepView" >
		<xsl:param name="fields"/>
		<xsl:variable name="item" select="." />
	</xsl:template>
	<xsl:template name="TestWorkflowStepView" >
		<xsl:param name="fields"/>
		<xsl:variable name="item" select="." />
		<div class="workflowStepItem">
			<span class="workflowStepName">
				<xsl:value-of select="$fields[@Name='TestTypeLookup']/@DisplayName"></xsl:value-of>
				<xsl:text>:</xsl:text>
			</span>
			<span class="workflowStepValue">
				<xsl:value-of select="$item/@TestTypeLookup" disable-output-escaping="yes"/>
			</span>
		</div>
		<div class="workflowStepItem">
			<span class="workflowStepName">
				<xsl:value-of select="$fields[@Name='TestResultPointsMax']/@DisplayName"></xsl:value-of>
				<xsl:text>:</xsl:text>
			</span>
			<span class="workflowStepValue">
				<xsl:value-of select="$item/@TestResultPointsMax" disable-output-escaping="yes"/>
			</span>
		</div>
	</xsl:template>

	<!-- Disable "Add new item" link below list -->
	<xsl:template name="Freeform" ddwrt:ghost="hide">
	</xsl:template>

</xsl:stylesheet>